<template>
  <div>
    <input type="button" value="浪起来" @click="fn" />
    <input type="button" value="停止" @click="fn1" />

    <h3>{{ msg }}</h3>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: "我拿Buff,谢谢~",
      timer: null
    };
  },
  methods: {
    fn() {
      if(this.timer!==null) return
        this.timer = setInterval(()=>{
        const header = this.msg.slice(0, 1);
        const body = this.msg.slice(1);
        this.msg = body + header;
        },300)
    },
    fn1(){
      clearInterval(this.timer);
      this.timer = null
    }
  },
};
</script>

<style scoped></style>
